import Vue from 'vue'
import Router from 'vue-router'
import {
  Toast
} from 'mint-ui';



import Home from "@/pages/home"
import classification from "@/pages/home/classification"
import friend from "@/pages/friend"
import find from "@/pages/find"
import purse from "@/pages/purse"
import purseDetail from "@/pages/purse/detail"
import exchange from "@/pages/purse/exchange"
import rolloff from "@/pages/purse/rolloff"
import into from "@/pages/purse/into"
import my from "@/pages/my"
import login from "@/pages/login/login"
import account from "@/pages/my/account"
// import {
//   resolve
// } from 'dns';

import live_screencap from "../pages/live/screencap"
import live_edit from "../pages/live/edit"

Vue.use(Router)

const router = new Router({
  routes: [{
      path: '/',
      name: 'Home',
      component: Home,
      // redirect: 'login'
    },
    // {
    //   path: "/setting",
    //   name: "test",
    //   component: resolve => require(['@/pages/setting'], resolve)
    // },
    {
      path: '/login',
      name: 'login',
      component: login
    },
    {
      path: '/test',
      name: 'test',
      component: resolve => require(['@/pages/test.vue'], resolve)
    },
    {
      path: "/classification",
      name: "classification",
      component: classification
    },
    {
      path: "/gameDetail",
      name: "gameDetail",
      component: resolve => require(['@/pages/home/gameDetail'], resolve)
    },
    {
      path: "/recommended",
      name: "recommended",
      component: resolve => require(['@/pages/home/recommended'], resolve)
    },
    //{
    // path: "/hostList",
    // name: "hostList",
    // component: resolve => require(['@/pages/home/hostList'], resolve)
    //},
    {
      path: '/friend',
      name: 'friend',
      component: friend,
      children: [{
          path: "",
          component: resolve => require(['@/pages/friend/com/news'], resolve)
        },
        {
          path: "chat",
          component: resolve => require(['@/pages/friend/com/chat'], resolve)
        },
        {
          path: "friendList",
          component: resolve => require(['@/pages/friend/com/friendList'], resolve)
        },

      ]
    },

    {
      path: "/redEdit",
      name: "edit",
      component: resolve => require(['@/pages/friend/redPacket/edit'], resolve)
    },
    {
      path: "/personal",
      name: "personal",
      component: resolve => require(['@/pages/friend/personal'], resolve)
    },
    {
      path: "/remark",
      name: "remark",
      component: resolve => require(['@/pages/friend/remark'], resolve)
    },
    {
      path: "/bagDetail1",
      name: "bagDetail",
      component: resolve => require(["@/pages/friend/redPacket/bagDetail"], resolve)
    },
    {
      path: "/rob",
      name: "rob",
      component: resolve => require(['@/pages/friend/com/rob'], resolve)
    },
    {
      path: "/coze",
      name: 'coze',
      component: resolve => require(['@/pages/friend/coze'], resolve)
    },
    {
      path: "/addFriend",
      component: resolve => require(['@/pages/friend/addFriend'], resolve)
    },
    {
      path: "/addTeam",
      component: resolve => require(['@/pages/friend/addTeam'], resolve)
    },
    {
      path: "/addTeamMember",
      component: resolve => require(['@/pages/friend/addTeamMember'], resolve)
    },
    {
      path: '/find',
      name: 'find',
      component: find
    },
    {
      path: '/purse',
      name: 'purse',
      component: purse,
    },
    {
      path: "/detail/:id",
      name: purseDetail,
      component: purseDetail
    },
    {
      path: '/exchange',
      name: 'exchange',
      component: exchange,
    },
    {
      path: '/rolloff',
      name: 'rolloff',
      component: rolloff,
    },
    {
      path: '/into',
      name: 'into',
      component: into,
    },
    {
      path: '/my',
      name: 'my',
      component: my,
    },
    {
      path: "/account",
      name: "account",
      component: account
    },
    {
      path: "/record",
      name: "record",
      component: resolve => require(['@/pages/purse/record'], resolve)
    },
    {
      path: "/gift",
      name: "gift",
      component: resolve => require(['@/pages/my/gift'], resolve)
    },
    {
      path: "/store",
      name: "store",
      component: resolve => require(['@/pages/my/store'], resolve)
    },
    {
      path: "/compile",
      name: "compile",
      component: resolve => require(['@/pages/my/compile'], resolve)
    },
    {
      path: "/recharge",
      name: "recharge",
      component: resolve => require(['@/pages/my/recharge'], resolve)
    },
    {
      path: "/signIn",
      name: "signIn",
      component: resolve => require(['@/pages/my/SignIn'], resolve)
    },
    {
      path: "/market",
      name: "market",
      component: resolve => require(['@/pages/my/dayMarket'], resolve)
    },
    //{
    // path: "/accountSettings",
    //name: "accountSettings",
    //component: resolve => require(['@/pages/my/accountSettings'], resolve)
    //},
    {
      path: "/topUp",
      name: "topUp",
      component: resolve => require(['@/pages/my/topUp'], resolve)
    },
    {
      path: "/download",
      name: "download",
      component: resolve => require(['../pages/downloadApp'], resolve)
    },
    {
      path: "/bag",
      name: "bag",
      component: resolve => require(['../pages/my/bag.vue'], resolve)
    },
    {
      path: "/giftBag",
      name: "giftBag",
      component: resolve => require(['../pages/my/GiftBagCode.vue'], resolve)
    },
    {
      path: "/bagDetail",
      name: "bagDetail",
      component: resolve => require(['../pages/my/bagDetail.vue'], resolve)
    },
    {
      path: "/bill",
      name: "bill",
      component: resolve => require(['../pages/my/bill.vue'], resolve)
    },
    {
      path: "/fund",
      name: "fund",
      component: resolve => require(['../pages/my/fund.vue'], resolve)
    },
    {
      path: "/common",
      name: "common",
      component: resolve => require(['../pages/common.vue'], resolve)
    },
    {
      path: "/encrypted",
      name: "encrypted",
      component: resolve => require(['../pages/my/encrypted.vue'], resolve)
    },
    {
      path: "/security",
      name: "security",
      component: resolve => require(['../pages/my/security.vue'], resolve)
    },
    {
      path: "/setPayPsw",
      name: "setPayPsw",
      component: resolve => require(['../pages/my/setPayPsw.vue'], resolve)
    },
    {
      path: "/live/screencap",
      name: "live_screencap",
      component: live_screencap
    },
    {
      path: "/live/operate",
      name: "live_operate",
      component: resolve => require(['@/pages/live/operate'], resolve)
    },
    {
      path: "/live/edit",
      name: "live_edit",
      component: live_edit
    },
    {
      path: "/live/lists",
      name: "live_lists",
      component: resolve => require(['@/pages/live/lists/index'], resolve)
    },
    {
      path: "/live/watch",
      name: "live_watch",
      component: resolve => require(['@/pages/live/lists/watch'], resolve)
    },

  ]
});

router.beforeEach((to, form, next) => {
  const isLogin = localStorage.getItem('zyLoginToken') ? true : false;
  if (to.path == "/friend" || to.path == '/find') {
    // downloadApp({
    //   type: "download"
    // });
  }
  if (to.path == '/login' || to.path == '/encrypted') {
    next();
  } else {
    if (isLogin) {
      next()
    } else {
      // Toast({
      //   message: "",
      //   duration: 2000
      // });
      next('/login');
    }
  }
})

export default router
